<?php

/**
 * video actions.
 *
 * @package    iEasy
 * @subpackage video
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class videoActions extends adminBase
{
    /**
     * Executes index action
     *
     * @param sfRequest $request A request object
     */
    public function executeIndex(sfWebRequest $request)
    {
        $navigator = "/backend.php/video/index?";
        $this->navigator = "";
        $this->catalogId = $request->getParameter("catalogId");
        $this->subCatalogId = $request->getParameter("subCatalogId");
        $this->contentTypeId = $request->getParameter("contentTypeId");
        $submitType = $request->getParameter("submitType");
        if ($submitType != null) {
            if ($submitType != "search") {
                $content = $request->getParameter("content");
                if (!empty($content)) {
                    $Ids = explode(" ", $content);
                    for ($i = 0; $i < count($Ids); $i++)
                    {
                        if (!empty($Ids[$i])) {
                            $currentVideo = @Doctrine_Core::getTable('Video')->find($Ids[$i]);
                            if (!empty($currentVideo)) {
                                switch ($submitType)
                                {
                                    case "delete": //
                                        $currentVideo->setStatusId(1006);
                                        $this->modifyVideoFocus($currentVideo, "delete");
                                        break;
                                    case "publish":
                                        if ($currentVideo->getStatusId() != 1005) {
                                            $currentVideo->setPublishTime(date("Y-m-d H:i:s"));
                                            $currentVideo->setStatusId(1005); //
                                        }
                                        $this->modifyVideoFocus($currentVideo, "publish");
                                        break;
                                    case "cancelPublish":
                                        $currentVideo->setModifyTime(date("Y-m-d H:i:s"));
                                        $currentVideo->setStatusId(1004); //不审核
                                        $this->modifyVideoFocus($currentVideo, "cancelPublish");
                                        break;
                                    case "recommend":
                                        $this->modifyVideoRecommend($currentVideo, "add");
                                        $currentVideo->setIsRecommendB("1");
                                        break;
                                    case "cancelRecommend":
                                        $this->modifyVideoRecommend($currentVideo, "delete");
                                        $currentVideo->setIsRecommendB("0");
                                        break;
                                    case "header":
                                        $this->modifyVideoHeader($currentVideo, "add");
                                        $currentVideo->setIsHeaderB("1");
                                        break;
                                    case "cancelHeader":
                                        $this->modifyVideoHeader($currentVideo, "delete");
                                        $currentVideo->setIsHeaderB("0");
                                        break;
                                    case "top":
                                        $currentVideo->setIsOnTopB("1");
                                        $this->modifyVideoRecommend($currentVideo, "top");
                                        $this->modifyVideoFocus($currentVideo, "top");
                                        //$this->modifyVideoHeader($currentVideo,"top");
                                        break;
                                    case "cancelTop":
                                        $currentVideo->setIsOnTopB("0");
                                        $this->modifyVideoRecommend($currentVideo, "cancelTop");
                                        $this->modifyVideoFocus($currentVideo, "cancelTop");
                                        //$this->modifyVideoHeader($currentVideo,"cancelTop");
                                        break;
                                    case "cancelFocus":
                                        $currentVideo->setIsFocusB("0");
                                        $this->modifyVideoFocus($currentVideo, "delete");
                                        break;
                                }
                                $currentVideo->save();
                            }
                        }
                    }
                }
            }
        }

        $this->recordCount = $request->getParameter('recordCount');
        $this->currentPage = $request->getParameter('currentPage');
        if (null == $this->recordCount || "" == $this->recordCount)
            $this->recordCount = 12;
        if (null == $this->currentPage || "" == $this->currentPage)
            $this->currentPage = 1;

        $query = Doctrine_Query::create()->from("Video v");
        $catalog = null;
        if ($this->catalogId != null) {
            $query = $query->where('catalog_id=' . $this->catalogId);
            $catalog = Doctrine_Core::getTable("Catalog")->find($this->catalogId);
            if ($catalog != null)
                $this->navigator = "<a href='" . $navigator . "catalogId=" . $catalog->getCatalogId() . "'>" . $catalog->getDescription() . "</a>";
        }

        $contentType = Doctrine_Core::getTable("ContentType")->find($this->contentTypeId);
        if ($contentType != null) {
            if ($this->navigator != "")
                $this->navigator = $this->navigator . " -> ";
            $this->navigator = $this->navigator . "<a href='" . $navigator . "contentTypeId=" . $contentType->getContentTypeId();
            if ($catalog != null)
                $this->navigator = $this->navigator . "&catalogId=" . $catalog->getCatalogId();
            $this->navigator = $this->navigator . "'>" . $contentType->getDescription() . "</a>";
        }
        if ($this->subCatalogId != null) {
            $query = $query->addwhere('sub_catalog_id=' . $this->subCatalogId);
            $subCatalog = Doctrine_Core::getTable("Catalog")->find($this->subCatalogId);
            if ($subCatalog != null) {
                if ($this->navigator != "")
                    $this->navigator = $this->navigator . " -> ";
                if ($catalog == null)
                    $this->navigator = $this->navigator . "<a href='" . $navigator . "?subCatalogId=" . $subCatalog->getCatalogId() . "'>" . $subCatalog->getDescription() . "</a>";
                else
                    $this->navigator = $this->navigator . "<a href='" . $navigator . "?catalogId=" . $catalog->getCatalogId() . "&subCatalogId=" . $subCatalog->getCatalogId() . "'>" . $subCatalog->getDescription() . "</a>";
            }

        }
        $this->searchProperty = $request->getParameter("searchProperty");
        $searchDelete = "false";
        switch ($this->searchProperty)
        {
            case "top":
                $query = $query->andWhere("is_on_top_b=1");
                break;
            case "recommend":
                $query = $query->andWhere("is_recommend_b=1");
                break;
            case "focus":
                $query = $query->andWhere("is_focus_b=1");
                break;
            //          case "header":
            //              $query = $query->andWhere("is_header_b=1");
            //              break;
            case "publish":
                $query = $query->andWhere("status_id=1005");
                break;
            case "delete":
                $searchDelete = "true";
                $query = $query->andWhere("status_id=1006");
                break;
        }
        $this->searchField = $request->getParameter("searchField");
        switch ($this->searchField)
        {
            case "title":
                $query = $query->andWhere("title like '%" . trim($request->getParameter("searchText")) . "%'");
                break;
            case "keyword":
                $query = $query->andWhere("keyword like '%" . trim($request->getParameter("searchText")) . "%'");
                break;
            case "tag":
                $query = $query->andWhere("tag like '%" . trim($request->getParameter("searchText")) . "%'");
                break;
            case "content":
                $query = $query->andWhere("body like '%" . trim($request->getParameter("searchText")) . "%'");
                break;
        }
        $this->searchText = trim($request->getParameter("searchText"));
        if ($this->searchField != null)
            $this->searchStr = $this->searchStr . "searchField=" . $this->searchField;
        else
        {
            if ($submitType != null && $submitType == "search") //默认搜索标题
                $query = $query->andWhere("title like '%" . trim($request->getParameter("searchText")) . "%'");
        }
        if ($this->searchProperty != null) {
            if ($this->searchStr != "")
                $this->searchStr = $this->searchStr . "&searchProperty=" . $this->searchProperty;
            else
                $this->searchStr = $this->searchStr . "searchProperty=" . $this->searchProperty;
        }
        if ($this->searchText != null)
            $this->searchStr = $this->searchStr . "&searchText=" . $this->searchText;
        if ($this->searchStr != "")
            $this->searchStr = "&" . $this->searchStr;
        if ($searchDelete == "false")
            $query = $query->andWhere("status_id != 1006");
        $query = $query->orderBy('v.publish_time desc,v.video_id desc');

        $this->pages = new sfDoctrinePager('Video', $this->recordCount); //$this->currentPage
        $this->pages->setQuery($query); //$q   数据库查询语句
        $this->pages->setPage($this->currentPage); //
        $this->pages->init();
    }


    public function executeEdit(sfWebRequest $request)
    {
        $this->video = new Video();
        $execSql = $request->getParameter("videoEdit");
        $this->results = "";
        $this->focTrue = "false";
        $this->recTrue = "false";
        $this->topTrue = "false";

        $this->focusCheck = "false";
        $this->recommendCheck = "false";
        $this->isOnTop = "false";
        $this->videoGroupIdHtml = "";
        if ($request->getParameter("content") == null)
            return $this->renderText("不合法的页面请求。");
        switch ($execSql) {
            case "1": //加载
                $content = $request->getParameter("content");

                $this->focusId = "";
                if (!empty($content)) {
                    $editVideo = @Doctrine_Core::getTable('Video')->find($content);
                    $this->videoGroupIdHtml = $this->getVideoGroupId($content, $editVideo->getPrimVideoGroupId());
                    if (!empty($editVideo)) {
                        if ($editVideo->getIsFocusB())
                            $this->focusCheck = "true";
                        if ($editVideo->getIsRecommendB())
                            $this->recommendCheck = "true";
                        if ($editVideo->getIsOnTopB())
                            $this->isOnTop = "true";
                        $this->video = $editVideo; //"s";//@$editVideo->delete();
                        if ($this->video->getIsFocusB()) //获取相关的焦点信息
                        {
                            $focuLine = Doctrine_Query::create()->from("FocusContent f")
                                    ->Where('content_id=' . $this->video->getVideoId())
                                    ->andWhere('content_type_i=1001')->execute();
                            foreach ($focuLine as $foc)
                            {
                                $this->focusId = $foc->getFocusContentId();
                                break;
                            }
                        }

                        $this->relatedVideo = $this->getRelatedInfo($editVideo->getVideoId(), "video");
                    }
                }
                break;
            case "2": //修改
                $content = $request->getParameter("content");
                if (!empty($content)) {
                    $video = @Doctrine_Core::getTable('Video')->find($content);
                    if (!empty($video)) {
                        $video->setCatalogId($request->getParameter("sCatalogId"));
                        $video->setSubCatalogId($request->getParameter("sContentCatalogId"));
                        $video->setPrimVideoGroupId($request->getParameter("sVedioGroupId"));
                        $video->setTitle($request->getParameter("title"));
                        $video->setArtist($request->getParameter("artist"));
                        $video->setSource($request->getParameter("source"));
                        $video->setTag($request->getParameter("tag"));
                        $video->setKeyword($request->getParameter("keyword"));
                        $video->setIsAuditB($request->getParameter("auditing"));
                        $video->setPublishTime($request->getParameter("nowtime"));
                        $video->setModifyTime(date("Y-m-d H:i:s"));
                        //$video->setHitI($request->getParameter("hit"));
                        $video->setOrderI(1);
                        $focus = $request->getParameter("ckFocusContent");
                        $recommend = $request->getParameter("ckRecommendContent");
                        $tops = $request->getParameter("ckTop");
                        if ($focus)
                            $video->setIsFocusB(1);
                        else
                            $video->setIsFocusB(0);
                        if ($recommend)
                            $video->setIsRecommendB(1);
                        else
                            $video->setIsRecommendB(0);
                        if ($tops)
                            $video->setIsOnTopB(1);
                        else
                            $video->setIsOnTopB(0);
                        $video->setHitMaskI($request->getParameter("hitMark"));
                        $video->setDuration($request->getParameter("duration"));
                        $video->setBrief($request->getParameter("brief"));
                        $video->setSnapshotBig($request->getParameter("Txt1")); //缩略图
                        $video->setLink($request->getParameter("Txt3")); //视频地址
                        $video->setIsHeaderB(0);
                        if ($request->getParameter("txtSubmitType") == "publish") {
                            //$video->setPublishTime($request->getParameter("nowtime"));
                            $video->setStatusId(1005);
                        }
                        $video->save();
                        $this->video = $video;
                        if ($focus) {
                            $focusContent = null;
                            $focuLine = Doctrine_Query::create()->from("FocusContent f")
                                    ->Where('content_id=' . $this->video->getVideoId())
                                    ->andWhere('content_type_i=1001')->execute();
                            foreach ($focuLine as $foc)
                            {
                                if ($foc->getFocusContentId() > 0)
                                    $focusContent = @Doctrine_Core::getTable('FocusContent')->find($foc->getFocusContentId());
                                break;
                            }
                            if ($focusContent == null) {
                                $focusContent = new FocusContent();
                                $focusContent->setCreateTime(date("Y-m-d H:i:s"));
                            }
                            $focusContent->setContentId($content);
                            $focusContent->setContentTypeI(1001);
                            $focusContent->setCatalogId($video->getCatalogId());
                            $focusContent->setModifyTime(date("Y-m-d H:i:s"));
                            if ($tops)
                                $focusContent->setIsOnTopB(1);
                            else
                                $focusContent->setIsOnTopB(0);
                            $focusContent->setSubTitle($request->getParameter("txtFocusTitle"));
                            $focusContent->setShortWord($request->getParameter("txtFocusBrief"));
                            $focusContent->setOrderI($video->getOrderI());
                            $focusContent->setFocusPhoto($request->getParameter("txtFocusLocalFile"));
                            $focusContent->setStatusId($video->getStatusId());
                            $focusContent->save();
                        } else
                        {
                            //删除焦点
                            $focuLine = Doctrine_Query::create()->from("FocusContent f")
                                    ->Where('content_id=' . $video->getVideoId())
                                    ->andWhere('content_type_i=1001')->execute();
                            foreach ($focuLine as $foc)
                            {
                                if ($foc->getFocusContentId() > 0) {
                                    $focusContent = @Doctrine_Core::getTable('FocusContent')->find($foc->getFocusContentId());
                                    @$focusContent->setStatusId(1006);
                                    $focusContent->save();
                                }
                            }
                        }

                        if ($recommend) {
                            $recomendContent = new RecommendContent();
                            $recomLine = Doctrine_Query::create()->from("RecommendContent r")
                                    ->Where('r.content_id=' . $video->getVideoId())
                                    ->andWhere('r.content_type_i=1001')->execute();
                            foreach ($recomLine as $recom)
                            {
                                if ($recom->getRecommendContentId() > 0)
                                    $recomendContent = @Doctrine_Core::getTable('RecommendContent')->find($recom->getRecommendContentId());
                                break;
                            }
                            $recomendContent->setCatalogId($video->getCatalogId());
                            $recomendContent->setContentId($video->getVideoId());
                            $recomendContent->setModifyTime(date("Y-m-d H:i:s"));
                            $recomendContent->setOrderI($video->getOrderI());
                            $recomendContent->setContentTypeI(1001);
                            if ($tops)
                                $recomendContent->setIsOnTopB(1);
                            else
                                $recomendContent->setIsOnTopB(0);
                            $recomendContent->save();
                        }
                        else
                        {
                            $recomLine = Doctrine_Query::create()->from("RecommendContent r")
                                    ->Where('r.content_id=' . $this->video->getVideoId())
                                    ->andWhere('r.content_type_i=1001')->execute();
                            foreach ($recomLine as $recom)
                            {
                                if ($recom->getRecommendContentId() > 0) {
                                    $recomendContent = @Doctrine_Core::getTable('RecommendContent')->find($recom->getRecommendContentId());
                                    @$recomendContent->delete();
                                }
                            }
                        }

                        if ($this->deleteRelatedContent($video->getVideoId()) >= 0) {
                            if ($request->getParameter("txtHideRelatedVideo") != "")
                                $this->insertRelatedContent($request->getParameter("txtHideRelatedVideo"), $video, 1001);
                        }
                        $url = "video/index?catalogId=" . $video->getCatalogId() . "&subCatalogId=" . $video->getSubCatalogId();
                        if ($request->getParameter("contentTypeId") != null)
                            $url = $url . "&contentTypeId=" . $request->getParameter("contentTypeId");
                        $this->redirect($url);
                        //$this->video=@Doctrine_Core::getTable('Video')->find($content);
                        //$this->results="修改成功！";
                    }
                }
                //$this->forward("video","index");
                break;
        }
    }

    public function executeAdd(sfWebRequest $request)
    {
        $this->execSql = $request->getParameter("videoEdit");
        $this->results = "";
        //switch($this->execSql){
        //case "1":
        if ($request->getParameter("title") != nuLL) {
            $video = new Video();
            $video->setCatalogId($request->getParameter("sCatalogId"));
            $video->setSubCatalogId($request->getParameter("sContentCatalogId"));
            $video->setTitle($request->getParameter("title"));
            $video->setArtist($request->getParameter("artist"));
            $video->setSource($request->getParameter("source"));
            $video->setTag($request->getParameter("tag"));
            $video->setKeyword($request->getParameter("keyword"));
            $video->setIsAuditB($request->getParameter("auditing"));
            if ($video->getIsAuditB() == 1)
                $video->setStatusId(1000);
            else
                $video->setStatusId(1004);
            $video->setPublishTime($request->getParameter("nowtime"));
            $video->setCreateTime(date("Y-m-d H:i:s"));
            $video->setModifyTime(date("Y-m-d H:i:s"));
            $video->setHitI(0);
            $video->setOrderI(1);
            $focus = $request->getParameter("ckFocusContent");
            $recommend = $request->getParameter("ckRecommendContent");
            $tops = $request->getParameter("ckTop");
            if ($focus)
                $video->setIsFocusB(1);
            else
                $video->setIsFocusB(0);
            if ($recommend)
                $video->setIsRecommendB(1);
            else
                $video->setIsRecommendB(0);
            if ($tops)
                $video->setIsOnTopB(1);
            else
                $video->setIsOnTopB(0);
            $video->setIsHeaderB(0);
            $video->setHitMaskI($request->getParameter("hitMark"));
            $video->setDuration($request->getParameter("duration"));
            $video->setBrief($request->getParameter("brief"));
            $video->setSnapshotBig($request->getParameter("Txt1")); //缩略图
            $video->setLink($request->getParameter("Txt3")); //视频地址
            $video->save();
            if ($focus) {
                $focusContent = new FocusContent();
                $focusContent->setContentId($video->getVideoId());
                $focusContent->setContentTypeI(1001);
                $focusContent->setCatalogId($video->getCatalogId());
                $focusContent->setCreateTime(date("Y-m-d H:i:s"));
                $focusContent->setModifyTime(date("Y-m-d H:i:s"));
                if ($tops)
                    $focusContent->setIsOnTopB(1);
                else
                    $focusContent->setIsOnTopB(0);
                $focusContent->setSubTitle($request->getParameter("txtFocusTitle"));
                $focusContent->setShortWord($request->getParameter("txtFocusBrief"));
                $focusContent->setOrderI($video->getOrderI());
                $focusContent->setFocusPhoto($request->getParameter("txtFocusLocalFile"));
                $focusContent->save();
            }
            if ($recommend) {
                $recomendContent = new RecommendContent();
                $recomendContent->setCatalogId($video->getCatalogId());
                $recomendContent->setContentId($video->getVideoId());
                $recomendContent->setCreateTime(date("Y-m-d H:i:s"));
                $recomendContent->setModifyTime(date("Y-m-d H:i:s"));
                $recomendContent->setOrderI($video->getOrderI());
                $recomendContent->setContentTypeI(1001);
                if ($tops)
                    $recomendContent->setIsOnTopB(1);
                else
                    $recomendContent->setIsOnTopB(0);
                $recomendContent->save();
            }
            if ($request->getParameter("txtHideRelatedVideo") != "")
                $this->insertRelatedContent($request->getParameter("txtHideRelatedVideo"), $video, 1001);
            $url = "video/index?catalogId=" . $video->getCatalogId() . "&subCatalogId=" . $video->getSubCatalogId();
            if ($request->getParameter("contentTypeId") != null)
                $url = $url . "&contentTypeId=" . $request->getParameter("contentTypeId");
            $this->redirect($url);
            //break;
        }
    }

    function insertRelatedContent($relatedStr, $video, $relatedContentTypeId)
    {
        $relatedArray = @explode(";", $relatedStr);
        foreach ($relatedArray as $key => $value)
        {
            $relatedContent = new RelatedContent();
            $relatedContent->setCreateTime(date("Y-m-d H:i:s"));
            $relatedContent->setModifyTime($relatedContent->getCreateTime());
            $relatedContent->setContentId($video->getVideoId());
            $relatedContent->setContentTypeI(1001);
            $relatedContent->setRContentId($value);
            $relatedContent->setRContentTypeI($relatedContentTypeId);
            $relatedContent->setCatalogId($video->getCatalogId());
            $relatedContent->save();
        }
    }

    function getRelatedInfo($videoId, $relatedType)
    {
        $query = Doctrine_Core::getTable("RelatedContent")->createQuery()
                ->where("content_id = ?", $videoId)
                ->addWhere("content_type_i = ?", 1001);
        $relatedStr = "";
        $query->addWhere("r_content_type_i = ?", 1001);

        $news = $query->execute();
        foreach ($news as $currentVideo)
        {
            //$relatedStr = $relatedStr.$currentVideo->getRContentId().";";
            if ($relatedStr == "")
                $relatedStr = $relatedStr . $currentVideo->getRContentId();
            else
                $relatedStr = $relatedStr . ";" . $currentVideo->getRContentId();
        }
        return $relatedStr;
    }

    function updateDataRows($sqlStr)
    {
        $dbBase = new DbBase();
        return $dbBase->update($sqlStr);
    }

    function deleteRelatedContent($videoId)
    {
        $sqlStr = "delete from RelatedContent where content_type_i = 1001 and content_id = " . $videoId;
        return $this->updateDataRows($sqlStr);
    }

    function modifyVideoRecommend($currentVideo, $actionType)
    {
        $recommend = Doctrine_Core::getTable("recommendContent")->createQuery()
                ->where("content_id=?", $currentVideo->getVideoId())
                ->andWhere("content_type_i=1001")
                ->execute()->getFirst();
        if ($actionType == "add") {
            if ($recommend == null) {
                $recommend = new RecommendContent();
                $recommend->setContentId($currentVideo->getVideoId());
                $recommend->setContentTypeI(1001);
                $recommend->setCreateTime(date("Y-m-d H:i:s"));
                $recommend->setModifyTime(date("Y-m-d H:i:s"));
                $recommend->setCatalogId($currentVideo->getCatalogId());
                $recommend->save();
            }
        }
        else
        {
            if ($recommend != null) {
                switch ($actionType)
                {
                    case "top":
                        $recommend->setIsOnTopB("1");
                        $recommend->save();
                        break;
                    case "cancelTop":
                        $recommend->setIsOnTopB("0");
                        $recommend->save();
                        break;
                    case "delete":
                        $recommend->delete();
                        break;
                }
            }
        }
    }

    function modifyVideoHeader($currentVideo, $actionType)
    {
        $header = Doctrine_Core::getTable("HeaderContent")->createQuery()
                ->where("content_id=?", $currentVideo->getVideoId())
                ->andWhere("content_type_i=1001")
                ->execute()->getFirst();
        if ($actionType == "add") {
            if ($header == null) {
                $header = new HeaderContent();
                $header->setContentId($currentVideo->getVideoId());
                $header->setContentTypeI(1001);
                $header->setCreateTime(date("Y-m-d H:i:s"));
                $header->setModifyTime(date("Y-m-d H:i:s"));
                $header->setCatalogId($currentVideo->getCatalogId());
                $header->save();
            }
        }
        else
        {
            if ($header != null) {
                switch ($actionType)
                {
                    case "top":
                        $header->setIsOnTopB("1");
                        $header->save();
                        break;
                    case "cancelTop":
                        $header->setIsOnTopB("0");
                        $header->save();
                        break;
                    case "delete":
                        $header->delete();
                        break;
                }
            }
        }
    }

    function modifyVideoFocus($currentVideo, $actionType)
    {
        $focus = Doctrine_Core::getTable("FocusContent")->createQuery()
                ->where("content_id=?", $currentVideo->getVideoId())
                ->andWhere("content_type_i=1001")
                ->execute()->getFirst();
        if ($focus != null) {
            switch ($actionType)
            {
                case "top":
                    $focus->setIsOnTopB("1");
                    break;
                case "cancelTop":
                    $focus->setIsOnTopB("0");
                    break;
                case "delete":
                    $focus->setStatusId(1006);
                    break;
                case "publish":
                case "cancelPublish":
                    $focus->setStatusId($currentVideo->getStatusId());
                    $focus->setCreateTime(date("Y-m-d H:i:s"));
                    break;
            }
            $focus->save();
        }

    }

    function getVideoGroupId($videoId, $videoGroupId)
    {
        $str = "";
        $sqlStr = "select * from VideoGroup where video_group_id in(select video_group_id from GroupVideoLink where video_id = " . $videoId . ")";
        $videoGroups = DbBase::getDataQuery($sqlStr);
        foreach ($videoGroups as $videoGroup)
        {
            $str = $str . "<option value='" . $videoGroup["video_group_id"] . "' ";
            if ($videoGroup["video_group_id"] == $videoGroupId)
                $str = $str . "selected='selected';";
            $str = $str . ">" . $videoGroup["title"] . "</option>";
        }
        return $str;
    }

    public function handleErrorContact()
    {
        $this->setTemplate('index');
        return sfView::SUCCESS;
    }

}
